//
// TcpServerConnectionFactory.h
//
// $Id: //poco/1.4/Net/include/Poco/Net/TcpServerConnectionFactory.h#1 $
//
// Library: Net
// Package: TcpServer
// Module:  TcpServerConnectionFactory
//
// Definition of the TcpServerConnectionFactory class.
//
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier:	BSL-1.0
//


#ifndef Net_TcpServerConnectionFactory_INCLUDED
#define Net_TcpServerConnectionFactory_INCLUDED


#include "Poco/Net/Net.h"
#include "Poco/Net/TcpServerConnection.h"


namespace Poco {
namespace Net {


class Net_API TcpServerConnectionFactory
	/// A factory for TcpServerConnection objects.
	///
	/// The TcpServer class uses a TcpServerConnectionFactory
	/// to create a connection object for each new connection
	/// it accepts.
	///
	/// Subclasses must override the createConnection()
	/// method.
	///
	/// The TcpServerConnectionFactoryImpl template class
	/// can be used to automatically instantiate a
	/// TcpServerConnectionFactory for a given subclass
	/// of TcpServerConnection.
{
public:
	virtual ~TcpServerConnectionFactory();
		/// Destroys the TcpServerConnectionFactory.

	virtual TcpServerConnection* createConnection(int fd) = 0;
		/// Creates an instance of a subclass of TcpServerConnection,
		/// using the given StreamSocket.

protected:
	TcpServerConnectionFactory();
		/// Creates the TcpServerConnectionFactory.

private:
	TcpServerConnectionFactory(const TcpServerConnectionFactory&);
	TcpServerConnectionFactory& operator = (const TcpServerConnectionFactory&);
};


template <class S>
class TcpServerConnectionFactoryImpl: public TcpServerConnectionFactory
	/// This template provides a basic implementation of
	/// TcpServerConnectionFactory.
{
public:
	TcpServerConnectionFactoryImpl()
	{
	}
	
	~TcpServerConnectionFactoryImpl()
	{
	}
	
	TcpServerConnection* createConnection(int fd)
	{
		return new S(fd);
	}
};


} } // namespace Poco::Net


#endif // Net_TcpServerConnectionFactory_INCLUDED
